/** \file    xml.h
  * \brief   Serialization of typelib objects in xml-stream.
  * \date    2003
  * \author  Fedor Chelnokov
  * \version $Header: /home/cscom1r4/cvsroot/cs/include/typelib/xml.h,v 1.1 2004/09/21 18:21:30 cscom1r4 Exp $
  */

#ifndef _typelib_xml_h_
#define _typelib_xml_h_

#include <xml/stream.h>

namespace types {
	template <class T> struct basic_affine;
	template <class T> class point;
	template <class T> class smooth_point;
	template <class T> class extent;
	template <class T> class rect;
}
using namespace types;

namespace xml {

template <class T>
inline stream & operator || (stream & s, basic_affine<T> & a)
{
	return
	s || def_attr("x",  a.x)
	  || def_attr("y",  a.y) 
	  || def_attr("xx", a.xx, T(1)) 
	  || def_attr("xy", a.xy) 
	  || def_attr("yx", a.yx) 
	  || def_attr("yy", a.yy, T(1));
}

template <class T>
inline stream & operator || (stream & s, point<T> & p)
{
	return s || def_attr("x", p.x) || def_attr("y", p.y);
}

template <class T>
inline stream & operator || (stream & s, smooth_point<T> & p)
{
	return s || point<T>(p) || child("t", p.t);
}

template <class T>
inline stream & operator || (stream & s, extent<T> & e)
{
	return s || def_attr("sx", e.sx) || def_attr("sy", e.sy);
}

template <class T>
inline stream & operator || (stream & s, rect<T> & r)
{
	return 
	s || def_attr("x1", r.x1) 
	  || def_attr("y1", r.y1)
	  || def_attr("x2", r.x2) 
	  || def_attr("y2", r.y2);
}

} //namespace xml

#endif //_typelib_xml_h_
